package com.ys.controller.api.sys;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.entity.sys.ToaNotice;
import com.ys.service.sys.CommonApiService;
import com.ys.service.sys.ToaNoticeService;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

/**
 * 通告信息维护
 */
@Controller
@RequestMapping("/api/inter/toaNotice")
public class ApiInterToaNoticeController {

    @Autowired
    private CommonApiService<ToaNotice> commonApiService;

    @Autowired
    private ToaNoticeService toaNoticeService;

    @RequiresPermissions("toaNotice:view")
    @RequestMapping("/search")
    @ResponseBody
    public LayuiTableVoJA search(@ModelAttribute ToaNotice cond){

        cond.setOrderby("A.Id DESC");
        
        cond.addLeftJoin("TS_UserChange B ON B.Id = A.CreateChangeId")
        	.addField("B.UserId createUserId")
        	.addField("B.UserName createUserName");
        return commonApiService.searchLay(cond);
    }


    /**
     * 新增
     */
    @RequiresPermissions("toaNotice:add")
    @RequestMapping("/add")
    @ResponseBody
    public R add(@RequestParam Map<String, Object> params) {
        return toaNoticeService.add(params);
    }


    /**
     * 修改
     */
    @RequiresPermissions("toaNotice:edit")
    @RequestMapping("/edit")
    @ResponseBody
    public R edit(@RequestParam Map<String, Object> params) {
        return toaNoticeService.edit(params);
    }
}
